package com.atguigu.gmall.all.controller.api;

import com.atguigu.gmall.model.order.OrderInfo;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author wk
 * @create 2021-09-14 13:59
 * 同步 使用@Controller
 */
@Controller
public class PayController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    // 去支付页面
    // window.location.href = 'http://payment.gmall.com/pay.html?orderId=' + response.data.data
    @GetMapping("/pay.html")
    public String pay(Long orderId, Model model) {
        // 远程调用获取 订单信息
        OrderInfo orderInfo = orderFeignClient.getOrderInfo(orderId);
        model.addAttribute("orderInfo", orderInfo);
        return "payment/pay";
    }
}
